<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>部门列表页面</title>
		<%--设置整个网页的基础路径是：--%>
		<%--<base href="http://localhost:8080/oa/">--%>
		<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
	</head>
	<body>

	<h3><欢迎${username},在线人数${onlinecount}人></h3>
	<a href="user/exit">[退出系统]</a>

		<script type="text/javascript">
			function del(dno) {
				var ok = window.confirm("亲，删了不可恢复哦！！！");
				if(ok){
					// document.location.href = "请求路径"
					// document.location = "请求路径"
					// window.location.href = "请求路径"
					// window.location = "请求路径"
					document.location.href = "${pageContext.request.contextPath}/dept/delete?deptno=" + dno;
				}
			}
		</script>
		<h1 align="center">部门列表</h1>
		<hr>
		<table border="1px" align="center" width="50%">
			<tr>
				<th>序号</th>
				<th>部门编号</th>
				<th>部门名称</th>
				<th>操作</th>
			</tr>

		<%--	<%
				// 从request域当中取出集合
				List<Dept> deptList = (List<Dept>) request.getAttribute("deptList");

				// 循环遍历
                int i = 0;
				for (Dept dept : deptList) {
					// 后台输出
					// System.out.println(dept.getDname());
					// 把部门名输出到浏览器
					// out.write(dept.getDname());
            %>--%>

			<c:forEach items="${deptList}" var="dept" varStatus="deptStatus">
            <tr>
                <td>${deptStatus.count}</td>
                <td>${dept.deptno}</td>
                <td>${dept.dname}</td>
                <td>
                    <a href="javascript:void(0)" onclick="del(${dept.deptno})">删除</a>
                    <a href="dept/detail?f=edit&dno=${dept.deptno}">修改</a>
                    <a href="dept/detail?f=detail&dno=${dept.deptno}">详情</a>
                </td>
            </tr>
			</c:forEach>

				<td colspan="4" align="center"><a href="add.jsp">新增部门</a></td>
			</tr>
		</table>
	</body>
</html>